export default {
  bind(el, binding) {
    let timer = null;

    const step = Number(el.getAttribute("step"))
      ? Number(el.getAttribute("step"))
      : 10; // 步长
    const suffix = el.getAttribute("suffix") ? el.getAttribute("suffix") : ""; // 后缀
    const targetDomCount = Number(binding.value); // 目标数字
    let nowCount = 0; //当前页面显示值
    timer = setInterval(() => {
      if (nowCount < targetDomCount) {
        nowCount += step;
      } else {
        nowCount = targetDomCount;
      }
      el.innerHTML = nowCount.toFixed(2) + suffix;
    }, 0);
  },
};
